<template>
	<view class="">
		<view @click="leftClick()" class="leftButton fixed-top " style="">
			<u-icon name="arrow-left" color="white" size="26"></u-icon>
		</view>

		<view class="flex-col page">

			<view class="flex-col group">
				<view class="" style="height: 100rpx;">

				</view>
				<view class="flex-col group_1">
					<view class="flex-col">
						<view class="flex-row section_1">
							<text class="text_1">账户</text>
							<input class="text_2" type="text" v-model.trim="account" placeholder="请输入账户" />
						</view>
						<view class="flex-row section_1">
							<text class="text_1">姓名</text>
							<input class="text_2" type="text" v-model.trim="name" placeholder="请输入姓名" />
						</view>
						<view class="flex-row section_2">
							<text class="text_3">性别</text>
							<u-radio-group style="margin-left: 48rpx;" v-model="sex" placement="row">
								<u-radio :customStyle="{'marginBottom': '8px'}" v-for="(item, index) in radiolist1"
									:key="index" style="margin-right: 8rpx;" activeColor=" rgb(24, 181, 103)"
									:label="item.name" :name="item.name">
								</u-radio>
							</u-radio-group>
						</view>


						<view class="section_3 justify-between">
							<view class="flex-row">
								<text class="text_10">代理城市</text>
								<tm-pickersCity @confirm="selectedCity" btn-color="bg-gradient-deep-purple-accent"
									class="text_11">
									<text>{{ city ? province+city+district : '选择意向工作城市' }}</text>
								</tm-pickersCity>
							</view>
							<image
								src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61ab188e1f655f0011bbaece/61e7d9270c0e3200129ec72c/16425844611732717437.png"
								class="image_5" />
						</view>

					</view>
					<view class="flex-row section_1">
						<text class="text_1">行业</text>
						<input class="text_2" type="text" v-model.trim="trade" placeholder="请输入行业" />
					</view>
					<view class="flex-row section_1">
						<text class="text_1">个人简介</text>
						<input class="text_2" type="text" v-model.trim="intro" placeholder="请输入个人简介" />
					</view>
					<view class="flex-row-center">
						<view class="flex-col items-center button" @click="submit">
							<text>提交</text>
						</view>
					</view>


				</view>
			</view>
			<!--城市选择-->
			<view class="yin" v-show="flag">
				<view class="boxserss">
					<view class="topser">
						<!-- 			<image class="topsrcomage" src="../../../static/demo/top.png"></image> -->
					</view>
					<view class="centerser">
						<image class="sersdrefuia" src="../../../static/demo/center.png"></image>
						<view class="tyop">{{mssg}}！</view>
					</view>

					<view class="textbackground" @click="goFan"><text>我知道了</text></view>

				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import tmPickersCity from '@/tm-vuetify/components/tm-pickersCity/tm-pickersCity.vue';
	import {
		uploadImage
	} from '@/config/utils'
	export default {
		components: {
			tmPickersCity
		},
		data() {
			return {
				radiolist1: [{
						name: '男',
						disabled: false
					},
					{
						name: '女',
						disabled: false
					}
				],
				mssg: '',
				// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
				account: '',
				name: '',
				sex: '男',
				trade: '',
				intro: '',

				realname: '',
				mobile: '',
				city: '',
				age: "",
				avatar: '',
				desc: '',
				status: '',
				flag: false,
				flag1: false,
				province: '',
				district: ''

			};
		},
		onLoad() {
			this.$http.post('api/user/detail', {}).then(res => {
				console.log(res.technician_apply_status, "打印的222222222222222222222")

				if (res.agency_status == 0) {
					this.mssg = ''

				} else if (res.agency_status == 2) {
					this.mssg = '您的审核已通过'
					this.flag = true

				} else if (res.agency_status == 1) {
					this.mssg = '审核中'
					this.flag = true
				}
			})


		},
		methods: {
			leftClick() {
				uni.navigateBack()
			},
			goFan() {
				uni.switchTab({
					url: '/pages/my/my'
				})

			},
			selectedCity(e) {
				this.city = e[1]
				this.province = e[0]
				this.district = e[2]
				console.log(this.city, "fnain")
			},
			upload() {
				uni.chooseImage({
					count: 1,
					success: (res) => {
						let {
							tempFilePaths
						} = res;
						let filePath = tempFilePaths[0]
						uploadImage(filePath).then(res => {
							this.avatar = res.path;
							console.log(res, '/*/*/*/*/');

						})
						console.log(tempFilePaths)
					}
				})
			},
			submit() {
				// if( !this.realname ){
				// 	uni.showToast({
				// 		icon:'none',
				// 		title:'请输入达人姓名'
				// 	});
				// 	return;
				// }
				// if( !(/^1[3456789]\d{9}$/.test(this.mobile)) ){
				// 	uni.showToast({
				// 		icon:'none',
				// 		title:'请输入正确格式的手机号'
				// 	});
				// 	return;
				// }
				// if( !this.age ){
				// 	uni.showToast({
				// 		icon:'none',
				// 		title:'请输入达人年纪'
				// 	});
				// 	return;
				// }
				// if( !this.city ){
				// 	uni.showToast({
				// 		icon:'none',
				// 		title:'请先选择意向工作城市'
				// 	});
				// 	return;
				// }
				if (!this.account) {
					uni.showToast({
						icon: 'none',
						title: '请输入账户'
					});
					return;
				}
				if (!this.name) {
					uni.showToast({
						icon: 'none',
						title: '请输入姓名'
					});
					return;
				}
				if (!this.city) {
					uni.showToast({
						icon: 'none',
						title: '请选择代理城市'
					});
					return;
				}
				if (!this.trade) {
					uni.showToast({
						icon: 'none',
						title: '请输入行业'
					});
					return;
				}
				if (!this.intro) {
					uni.showToast({
						icon: 'none',
						title: '请输入个人简介'
					});
					return;
				}
				this.$http.post('api/agency/apply', {
					account: this.account,
					name: this.name,
					sex: this.sex,
					city: this.city,
					trade: this.trade,
					intro: this.intro,
				}).then(res => {
					// plus.runtime.openURL( 'https://www.pgyer.com/Jix5');
					uni.showToast({
						icon: 'none',
						title: '已提交审核，请耐心等待'
					})
					setTimeout(() => {
						uni.navigateBack({
							delta: 1
						})
					}, 1000)
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	page {
		background-color: #ffffff00;
	}

	.BGImage1 {
		position: fixed;
		width: 100%;
		height: 100%;
		bottom: 0;
		top: 0;
		left: 0;
		z-index: -1;
	}

	.bgView {
		width: 100%;
		height: 100vh;
	}

	.bgView1 {
		width: 690rpx;
		height: 581rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		border: 10rpx solid #1E8554;
	}

	.image {
		width: 284rpx;
		height: 228rpx;
	}

	.title {
		margin-top: 12rpx;
		font-size: 34rpx;
		font-family: PingFang SC;
		// font-weight: 500;
		color: #333333;
	}

	.button {
		margin-top: 53rpx;
		width: 579rpx;
		height: 93rpx;
		background: #0DA17D;
		border-radius: 47rpx;
		font-size: 34rpx;
		font-family: PingFang SC;
		// font-weight: bold;
		color: #FFFFFF;
	}

	.topsrcomage {
		width: 100%;
		height: 100%;
	}

	.tyop {
		text-align: center;
	}

	.sersdrefuia {
		height: 550rpx;
	}

	.textbackground {
		width: 90%;
		height: 70rpx;
		background-color: #0da17d;
		color: white;
		border-radius: 50rpx;
		align-items: center;
		text-align: center;
		line-height: 70rpx;
		font-size: 30rpx;
		margin: 150rpx auto;
	}

	.centerser {
		width: 80%;
		height: 650rpx;
		background-color: white;
		border-radius: 15rpx;
		margin: -60rpx auto;
	}

	.topser {
		// background-color: #17ba92;
		width: 100%;
		height: 350rpx;
	}

	.boxserss {
		width: 100%;
		height: 100%;
		background-color: #f5f5f5;
	}

	.yin {
		width: 100%;
		height: 100%;
		position: fixed;
		background-color: rgba(0, 0, 0, 0.8);
		z-index: 999;

	}

	.dog {
		width: 70%;
		height: 10%;
		background-color: white;
		border-radius: 8rpx;
		margin: 100rpx auto;
		display: flex;
		align-items: center;
		justify-content: center;
	}



	.page {
		background-color: #f8f8f8;
		width: 100%;
		height: 100%;
		overflow-y: auto;

		.group {
			padding-bottom: 100rpx;
			flex: 1 1 auto;
			overflow-y: auto;

			.image_1 {
				width: 100%;
				height: 400rpx;
			}

			.group_1 {
				margin-top: -10rpx;
				padding: 0 32rpx;
				position: relative;

				.button {
					margin-top: 90rpx;
					padding: 22rpx 0;
					color: rgb(255, 255, 255);
					font-size: 32rpx;
					font-weight: 500;
					line-height: 44rpx;
					white-space: nowrap;
					background-color: rgb(24, 181, 103);
					border-radius: 44rpx;
				}

				.section_1 {
					padding: 28rpx 24rpx;
					background-color: rgb(255, 255, 255);
					border-radius: 24rpx 24rpx 0px 0px;

					.text_1 {
						color: rgb(0, 0, 0);
						font-size: 28rpx;
						font-weight: 500;
						line-height: 40rpx;
						white-space: nowrap;
					}

					.text_2 {
						margin-left: 48rpx;
						color: rgb(153, 153, 153);
						font-size: 28rpx;
						line-height: 40rpx;
						white-space: nowrap;
					}
				}

				.section_2 {
					padding: 24rpx 24rpx 26rpx;
					color: rgb(0, 0, 0);
					font-size: 28rpx;
					font-weight: 500;
					line-height: 40rpx;
					white-space: nowrap;
					background-color: rgb(255, 255, 255);

					.text_3 {
						margin-top: 4rpx;
					}

					.image_2 {
						width: 44rpx;
						height: 44rpx;
					}

					.image_3 {
						margin-left: 48rpx;
					}

					.text_4 {
						margin-left: 4rpx;
						margin-top: 4rpx;
					}

					.image_4 {
						margin-left: 40rpx;
					}

					.text_5 {
						margin-left: 4rpx;
						margin-bottom: 4rpx;
					}
				}

				.section_3 {
					padding: 28rpx 24rpx;
					background-color: rgb(255, 255, 255);

					.text_6 {
						color: rgb(0, 0, 0);
						font-size: 28rpx;
						font-weight: 500;
						line-height: 40rpx;
						white-space: nowrap;
					}

					.text_7 {
						margin-left: 48rpx;
						color: rgb(153, 153, 153);
						font-size: 28rpx;
						line-height: 40rpx;
						white-space: nowrap;
					}

					.text_8 {
						color: rgb(0, 0, 0);
						font-size: 28rpx;
						font-weight: 500;
						line-height: 40rpx;
						white-space: nowrap;
					}

					.text_9 {
						margin-left: 48rpx;
						color: rgb(153, 153, 153);
						font-size: 28rpx;
						line-height: 40rpx;
						white-space: nowrap;
					}

					.image_5 {
						margin-bottom: 6rpx;
						width: 32rpx;
						height: 32rpx;
					}

					.text_10 {
						color: rgb(0, 0, 0);
						font-size: 28rpx;
						font-weight: 500;
						line-height: 40rpx;
						white-space: nowrap;
					}

					.text_11 {
						margin-left: 48rpx;
						color: rgb(153, 153, 153);
						font-size: 28rpx;
						line-height: 40rpx;
						width: 450rpx;
					}
				}

				.section_4 {
					padding: 28rpx 23rpx 31rpx;
					color: rgb(0, 0, 0);
					font-size: 28rpx;
					font-weight: 500;
					line-height: 40rpx;
					white-space: nowrap;
					background-color: rgb(255, 255, 255);
					border-radius: 0px 0px 24rpx 24rpx;

					.group_4 {
						margin-top: 31rpx;
						padding: 71rpx 0 71rpx;
						position: relative;

						.image_6 {
							margin-left: 71rpx;
							width: 56rpx;
							height: 56rpx;
						}

						.image_7 {
							border-radius: 24rpx;
							width: 198rpx;
							height: 198rpx;
							position: absolute;
							left: 0;
							top: 0;
						}

						.avatar {
							border-radius: 24rpx;
							position: absolute;
							width: 198rpx;
							height: 198rpx;
							position: absolute;
							left: 0;
							top: 0;
							z-index: 9;
						}
					}
				}
			}
		}
	}
</style>